#!/bin/sbin/

#判断是否安装nginx
find / -name nginx | grep sbin/nginx &>/dev/null
if [ $? -eq 0  ];then
	echo "nginx已准备好"
else		
	find / -name 'nginx*' | grep *.gz &>/dev/null
	if [ $? -ne 0 ];then
		echo "请将nginx的tar包放在root家目录下"
		exit
	else  #判断nginx需要的库是否安装,安装基础软件包
                rpm -qa | grep pcre-devel &>/dev/null
                [ $? -eq 0 ] && yum -y install pcre-devel &>/dev/null
                rpm -qa | grep zlib-devel &>/dev/null
                [ $? -eq 0 ] && yum -y install zlib-devel &>/dev/null
                yum -y install gcc gcc-c++ make &>/dev/null
                #释放归档文件配置编译安装
                tar xf nginx-1.6.0.tar.gz -C /usr/src 
                cd /usr/src/nginx-1.6.0
                echo "安装中..."
                ./configure --prefix=/usr/local/nginx &>/dev/null && make &>/dev/null && make install &>/dev/null
                if [ $? -ne 0 ];then
		 	echo "安装失败"
			exit 
		else
			echo "nginx安装成功"
		fi
	fi

fi